package
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
	import flash.utils.Timer;
	
	import org.osmf.events.TimeEvent;
	
	[SWF(width="800", height="600", backgroundColor="#ffffff", frameRate="31")]
	public class dreamTest extends Sprite
	{
		private const TIME:int = 30;
		private var _load:Loader;
		private var timer:Timer = new Timer(TIME);
		private var loadMusic:Loader = new Loader();
		private var titleMusic:Sound = new Sound();
		private var titleMusic_sec:Sound = new Sound()
		private var soundChannel:SoundChannel = new SoundChannel();
		private var _loadMusic:Loader = new Loader();
		public function dreamTest(){
			drawFrame();
		}
		public function drawFrame(){
			_load = new Loader();
			var str :String = "../res/image/dq9.jpg";
			_load.load(new URLRequest(str));
			_load.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComImage);
			_load.x = 200;
			_load.y = -150;
			
			var musicUrl:String = "../res/music/title.mp3";
			titleMusic.load(new URLRequest(musicUrl));
			titleMusic.addEventListener(Event.COMPLETE,loadComMusic)
				
			var musicUrl:String = "../res/music/fight.mp3";
			titleMusic_sec.load(new URLRequest(musicUrl));
			titleMusic_sec.addEventListener(Event.COMPLETE,loadComMusic_sec)
			
			timer.start();
			timer.addEventListener(TimerEvent.TIMER,check);
			
		}
		
		private function loadComImage(e:Event){
		
		}
		private function loadComMusic_sec(e:Event){
			soundChannel = titleMusic_sec.play();
		}
		private function loadComMusic(e:Event){
			addChild(_load);
			soundChannel = titleMusic.play();
		}
		private function check(e:TimerEvent){
			_load.y +=1;
			if(_load.y >= 10)
			{
				timer.stop();
				timer.removeEventListener(TimerEvent.TIMER,check);
			}
		}
	}
}